package cn.wolfcode.trip.base.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;

/**
 * 系统消息的实体类
 * @author lishuanwang
 */
@Getter
@Setter
public class Information {
    /**
     * SYSTEM_MESSAGE: 默认值,系统消息,发给所有用户,例如注册欢迎信息
     * GROUP_MESSAGE:群组信息,发给某类人,比如同时2级的用户,可用于扩展
     * USER_MESSAGE:用户消息,针对于某一个用户
     */
    public static final int SYSTEM_MESSAGE_PUBLISH = 1;
    public static final int SYSTEM_MESSAGE_CANCEL_PUBLISH = 2;
    public static final int SYSTEM_MESSAGE_ALL = 3;
    public static final int USER_MESSAGE_LIKE = 4;
    public static final int USER_MESSAGE_COLLECTION = 5;
    public static final int USER_MESSAGE_COMMENT = 6;
    public static final int USER_MESSAGE_VERIFY= 7;

    /**
     * 消息id,标志唯一消息
     */
    private Long id;
    /**
     * 消息类型,默认为系统消息
     */
    private Integer type = SYSTEM_MESSAGE_ALL;
    /**
     * 消息标题
     */
    private String title;
    /**
     * 消息内容
     */
    private String content;
    /**
     * 消息的创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd" , timezone = "GMT+08:00")
    private Date createTime;
    /**
     * 消息生产人员
     */
    private User user;

    /**
     * 保存关系
     * @return
     */
    private UserInformation userInformation;

    /**
     * 获取信息类型
     * @return
     */
    public String getTypeName(){
        String temp = "系统消息";
        if (type == SYSTEM_MESSAGE_ALL){
            temp ="群消息";
        }else if (type == USER_MESSAGE_LIKE){
            temp="用户消息:点赞";
        }else if (type == USER_MESSAGE_COLLECTION){
            temp="用户消息:收藏";
        }else if (type == USER_MESSAGE_COMMENT){
            temp="用户消息:评论";
        }
        return temp;
    }

}